﻿using System;
using System.Collections.Generic;
using System.Text;
using JEng_Mark_1.Interfaces;
using Microsoft.Xna.Framework.Graphics;
using JEng_Mark_1.Managers;

namespace JEng_Mark_1.Textures
{
    public class JTexture : IJEngTexture
    {
        #region IJEngTexture Members
        private string _fileName;
        /// <summary>
        /// Get / set the file location of this texture
        /// </summary>
        public string FileName
        {
            get
            {
                return _fileName;
            }
            set
            {
                _fileName = value;
            }
        }

        private Texture _baseTexture;
        /// <summary>
        /// Get the underlying texture
        /// </summary>
        public Texture BaseTexture
        {
            get { return _baseTexture; }
        }
        private bool _readyToRender = false;

        /// <summary>
        /// Is this texture loaded and initialized?
        /// </summary>
        public bool ReadyToRender
        {
            get { return _readyToRender; }
        }

        /// <summary>
        /// Construct a new texture
        /// </summary>
        public JTexture() { }

        /// <summary>
        /// Construct a new texture from a file
        /// </summary>
        /// <param name="fileName">File to load for texture</param>
        public JTexture(string fileName)
        {
            _fileName = fileName;
        }

        public void LoadContent()
        {
            if (!String.IsNullOrEmpty(_fileName))
            {
                _baseTexture = JEngineManager.ContentManager.Load<Texture>(_fileName);
                _readyToRender = true;
            }
        }

        public void UnloadContent()
        {
            _baseTexture.Dispose();
        }

        #endregion
    }
}
